<template>
	<view class="content">
		<!-- #ifdef H5 || APP-PLUS -->
		<view class="message-title">
			<commonTitle title="我的粉丝"></commonTitle>
		</view>
		<!-- #endif -->
		<view class="list-scroll-content">
			
			<scroll-view class="my-share-detail" scroll-y="true"
			 v-if="list.length>0"
			 @scrolltolower="loadMore">
					<view class="ranking-item"v-for="(item,index) in list">
						<view class="item-left">
							<image :src="getImg(item.headimg)" class="avatar"></image>
							<view class="item-user">
								<view class="ranking-num">{{item.nickName}}</view>
								<view class="user-id">{{item.phone}}</view>
							</view>
						</view>
						<view class="get-money">{{getTime(item.createTime.time)}}</view>
					</view>
				
			</scroll-view>
			
			<view class="nodata" v-else>
				<image src="../../static/common/nodata-sub.png" class="nodata-img"></image>
			</view>
			
			
		</view>
		
		
		
	</view>
</template>

<script>
	const util = require('../../util/util.js');
	import commonTitle from'../../components/titile/title.vue'
	export default{
		components:{
			commonTitle
		},
		data () {
			return {
				apptoken:"",
				list:[],
				nodata:false,
				pageIndex:1
			}
		},
		onLoad() {
			this.apptoken = uni.getStorageSync("apptoken");
			this.getFansList();
		},
		methods: {
			getTime(time){
				return this.$CommonJS.getTime(time,1)
			},
			getImg(img){
				return this.$CommonJS.getBaseImgUrl(img)
			},
			getFansList(type){
				const _this = this;
				uni.request({
					url:this.$API.URL + this.$API.fansList,
					data:{ apptoken:this.apptoken, pageIndex:this.pageIndex },
					success(res) {
						console.log(res);
						if(res.data.success){
							const d = res.data.data;
							if(d.length<1 && _this.pageIndex!=1){
								_this.nodata = true;
								_this.$CommonJS.showToast("没有更多数据了")
							}else{
								if(type){
									//分页
									d.forEach(item=>{
										_this.list.push(item);
									})
								}else{
									_this.list = d;
								}
							}
							_this.pageIndex++;
						}else{
							_this.$CommonJS.showToast(res.data.msg)
						}
					}
				})
			},
			loadMore: util.throttle(function(e) {
				if(!this.nodata){
					this.getFansList('loadMore')
				}
				
			}, 300),
		}
		
	}
</script>

<style>
	@import url("my-fans.css");
	.nodata{
		width: 100%;
		height: 500upx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
	.nodata-img{
		width: 161upx;
		height: 161upx;
	}
</style>
